/*
 * Copyright(C) 2019 FUYUN DATA SERVICES CO.,LTD. - All Rights Reserved
 * Unauthorized copying of this file, via any medium is strictly prohibited
 * Proprietary and confidential
 * 该源代码版权归属福韵数据服务有限公司所有
 * 未经授权，任何人不得复制、泄露、转载、使用，否则将视为侵权
 *
 */

import { init, RematchRootState } from '@rematch/core';
import * as models from './models';
import createLoadingPlugin from '@rematch/loading';
import selectorsPlugin from '@rematch/select';
const select = selectorsPlugin();

const loadingPlugin = createLoadingPlugin({ asNumber: false });
interface ILoadingPlugin {
  loading: {
    models: RematchRootState<typeof models>;
    effects: Dispatch;
  };
}
export const store = init({
  plugins: [loadingPlugin, select],
  models
});

export type Store = typeof store;
export type Dispatch = typeof store.dispatch;
export type IRootState = RematchRootState<typeof models> & ILoadingPlugin;
